package cn.josh.action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.josh.bean.Ec_shopcar;
import cn.josh.service.Ec_shopcarService;
import cn.josh.servicelmpl.Ec_shopcarServiceImpl;


@WebServlet("/ArticleCarDeleteServlet")
public class ArticleCarDeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		//得到用户id
		HttpSession session = request.getSession();
		String userId = (String)session.getAttribute("userId");
		System.out.println("ArticleCarDeleteServlet---userId:" + userId);
		
		//得到商品id
		String articleId = (String)request.getParameter("articleId");
		System.out.println("商品id是：" + articleId);
		
		//将对象封装
		Ec_shopcar shopcar = new Ec_shopcar();
		shopcar.setUserId(userId);
		shopcar.setArticleId(articleId);
		
		//调用数据库服务
		Ec_shopcarService ec_ser = new Ec_shopcarServiceImpl();
		ec_ser.deleteShop(shopcar);
		
		//跳转 做界面读取
		response.sendRedirect("/ShoppingWebsite/ArticleCarReadServlet");	
		
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
